package com.ktgj.pay.api;

import com.ktgj.common.core.constant.ServiceNameConstants;
import com.ktgj.common.core.domain.R;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.pay.api.domain.*;
import com.ktgj.pay.api.factory.RemoteWeChatPayFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 会员服务
 * @author ruoyi
 */
@Repository
@FeignClient(contextId = "RemotePayService", value = ServiceNameConstants.PAY_SERVICE, fallbackFactory = RemoteWeChatPayFallbackFactory.class)
public interface RemotePayService
{

    @RequestMapping("/weChatPay/createNative")
    public R<Map> createNative(@RequestParam("orderId") Long orderId, @RequestParam("body") String body, @RequestParam("out_trade_no") String out_trade_no, @RequestParam("totalFee") BigDecimal totalFee);

    /**
     * 获取微信支付参数(JSAPI)
     * attach 自定义参数
     * money 实际支付金额
     * orderNumber 订单号
     * notifyUrl 回调地址 "http://39.106.54.2:8080/WXPay/orderResult"
     */
    @RequestMapping("/weChatPay/getWechatJSAPIPayParam")
    public R<Map> getWechatJSAPIPayParam(@RequestParam("openId") String openId, @RequestParam("money") BigDecimal money,
                                             @RequestParam("orderNumber") String orderNumber, @RequestParam("notifyUrl") String notifyUrl);

    @RequestMapping("/weChatPay/refundWechat")
    public AjaxResult refundWechat(@RequestParam("orderNumber") String orderNumber, @RequestParam("refundNumber") String refundNumber,
                                   @RequestParam("notifyUrl") String notifyUrl, @RequestParam("refundMoney") BigDecimal refundMoney,
                                   @RequestParam("totalMoney") BigDecimal totalMoney);

//    /**
//     * 根据业务类型查询支付方式
//     * @return
//     */
//    @PostMapping("/type/queryPayType")
//    public List<PayTypeApi> queryPayType(@RequestBody Map<String, Object> map);

    /**
     * 根据业务类型查询支付方式
     * @param businessType
     * @return
     */
    @PostMapping("/type/queryPayType")
    public List<PayTypeApi> queryPayType(@RequestParam("businessType") String businessType);

    /**
     * 银行信用卡消费
     * */
    @PostMapping("/bankPay/bankCreditSale")
    public YeeBaoResultApi CreditSale(@RequestBody BankPayInfoApi bankPayInfo);

    /**
     * 验证码确认消费
     */
    @PostMapping("/bankPay/VerifySale")
    public YeeBaoResultApi VerifySale(@RequestBody Map<String, Object> map);

    /**
     * 订单验证码获取
     * @param jsjOrderId
     * @return
     */
    @PostMapping("/bankPay/VerifyCodeReceive")
    public YeeBaoResultApi VerifyCodeReceive(@RequestBody String jsjOrderId);

    /**
     * 银行借记卡消费
     * */
    @PostMapping("/bankPay/bankDebitSale")
    public YeeBaoResultApi DebitSale(@RequestBody BankPayInfoApi bankPayInfo);

    /**
     * 银行借记卡退款
     * @param map
     * @return
     */
    @PostMapping("/bankPay/bankDebitRefund")
    public YeeBaoResultApi bankDebitRefund(@RequestBody Map<String, String> map);

    /**
     * 银行信用卡退款
     * @param map
     * @return
     */
    @RequestMapping("/bankPay/bankCreditRefund")
    public YeeBaoResultApi bankCreditRefund(@RequestBody Map<String, String> map);

    /**
     * 银联二维码支付码获取
     * @param map
     * @return
     */
    @PostMapping("/unionQRCodePay/getQRCode")
    public UnionPayQRCodeResponseApi getQRCode(@RequestBody Map<String,String> map);

    /**
     * 银联二维码退款
     * @param map
     * @return
     */
    @PostMapping("/unionQRCodePay/qrCodeRefund")
    public UnionPayQRCodeResponseApi qrCodeRefund(@RequestBody Map<String,String> map);

    /**
     * 银联二维码订单信息查询
     * @param map
     * @return
     */
    @PostMapping("/unionQRCodePay/queryQRCodeOrder")
    public AjaxResult queryQRCodeOrder(@RequestBody Map<String,String> map);

    /**
     * 验证是否通过
     * @param resultMap
     * @return
     */
    @RequestMapping("/weChatPay/isPaySuccessful")
    public boolean isPaySuccessful(@RequestBody Map<String, String> resultMap);

    /**
     * 语音支付（远程）
     * */
    @PostMapping("/phoneSoundPay/voicePay")
    public String voicePay(@RequestBody Map<String, Object> map);

    /**
     * 会员发票订单列表（CRM）
     * */
    @PostMapping("/invoiceOrder/getListByCustomerId")
    public List<InvoiceInvoiceOrderApi> getListByCustomerId(@RequestBody String jsjid);

    //获取支付宝签名（远程）
    @PostMapping("/aliPay/postAliPayParam")
    public String postAliPayParam(@RequestBody Map<String, Object> map);

    /**
     * 银联支付（远程）
     * */
    @PostMapping("/unionPay/postUnionPayParam")
    public String postUnionPayParam(@RequestBody Map<String, Object> map);

    /**
     * 新增发票订单
     * @param invoiceInvoiceOrder
     * @return
     */
    @PostMapping("/invoiceOrder/add")
    public AjaxResult add(@RequestBody InvoiceInvoiceOrder invoiceInvoiceOrder);

    /**
     * 通过机票订单id查询发票配送状态
     *
     * @param orderId
     * @return
     */
    @PostMapping("/delivery/queryEmailState")
    public int queryEmailState(@RequestParam("orderId") Long orderId);
}
